package com.beauxi.activities;

import com.beauxi.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class CromoReversoActivity extends Activity {
	Integer id;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cromo_reverso);
        
       
        ImageView iv = (ImageView) findViewById(R.id.imageView2);
        id = savedInstanceState != null ? savedInstanceState.getInt("id_rev"): null;
        
        if (id == null || id==0) {
			Bundle extras = getIntent().getExtras();
			id = extras != null
				? extras.getInt("id_rev")
				: null;
		}
        
        String name = getResources().getResourceEntryName(id);
        String defType = getResources().getResourceTypeName(id);
        String defPackage = getResources().getResourcePackageName(id);
        name = name.replace("beauxi", "beauxi_reverso");
        
        Integer idOld = getResources().getIdentifier(name, defType, defPackage);
        iv.setImageResource(idOld.intValue());
        iv.setClickable(true);
        
        iv.setOnClickListener(new OnClickListener() {
        	@Override
			public void onClick(View v) {
				Intent i = new Intent(CromoReversoActivity.this,CromoDetalleActivity.class);
                ImageView iv = (ImageView) v;
            	i.putExtra("_id", id);
            	startActivity(i);
			}
		});
       
    }
}